"use strict";
cc._RF.push(module, 'c329bEGm2NJH6dgnUcy3NG4', 'MainLayer');
// Script/MainLayer.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var JoyStick_1 = require("./JoyStick");
var EventManager_1 = require("./Managers/EventManager");
var AppEvent_1 = require("./Core/AppEvent");
var AppDef_1 = require("./Core/AppDef");
var WindowUtils_1 = require("./Tools/WindowUtils");
var MainLayer = /** @class */ (function (_super) {
    __extends(MainLayer, _super);
    function MainLayer() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.joyStick = null;
        _this.weaponJoyStick = null;
        _this.tempJoyStick = null;
        return _this;
    }
    MainLayer.prototype.onLoad = function () {
        this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
        this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
        this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
        this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
        this.joyStick.active = false;
        this.weaponJoyStick.active = false;
        EventManager_1.dispatchEvent(AppEvent_1.EVT_CREATE_PLAYER, { playerType: AppDef_1.PLAYER_TYPE.My, weapontype: AppDef_1.WEAPON_TYPE.My,
            posx: WindowUtils_1.default.DEVICE_W / 2 - 200, posy: WindowUtils_1.default.DEVICE_H / 2 });
        EventManager_1.dispatchEvent(AppEvent_1.EVT_CREATE_PLAYER, { playerType: AppDef_1.PLAYER_TYPE.Enumy, weapontype: AppDef_1.WEAPON_TYPE.Enumy,
            posx: 1000, posy: 550 });
    };
    MainLayer.prototype.onTouchStart = function (event) {
        if (event.getLocation().x < 640) {
            this.tempJoyStick = this.joyStick;
        }
        else {
            this.tempJoyStick = this.weaponJoyStick;
        }
        this.tempJoyStick.active = true;
        this.tempJoyStick.getComponent(JoyStick_1.default).onTouchStart(event);
    };
    MainLayer.prototype.onTouchMove = function (event) {
        this.tempJoyStick.active = true;
        this.tempJoyStick.getComponent(JoyStick_1.default).onTouchMove(event);
    };
    MainLayer.prototype.onTouchEnd = function (event) {
        this.tempJoyStick.active = false;
        this.tempJoyStick.getComponent(JoyStick_1.default).onTouchEnd(event);
    };
    __decorate([
        property(cc.Node)
    ], MainLayer.prototype, "joyStick", void 0);
    __decorate([
        property(cc.Node)
    ], MainLayer.prototype, "weaponJoyStick", void 0);
    MainLayer = __decorate([
        ccclass
    ], MainLayer);
    return MainLayer;
}(cc.Component));
exports.default = MainLayer;

cc._RF.pop();